package com.xzy.mapper;

import com.xzy.entity.mReport;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component(value = "mReportMapper")
public interface mReportMapper {
    @Insert("insert into mreport(userId,departmentId,mreportName,mreportDate,status,summaryContents,planContents) values (#{userId},#{departmentId},#{mreportName},#{mreportDate},#{status},#{summaryContents},#{planContents})")
    void addmReport(mReport mreport);
    @Select("select * from mreport where mreportName=#{mreportName} and mreportDate=#{mreportDate}")
    mReport getmReportByName(String mreportName,int mreportDate);
    @Select("select * from mreport where reportDate=#{reportDate}")
    List<mReport> getmReportByDate(int reportDate);
    @Select("select * from mreport where mreportId=#{mreportId}")
    mReport getmReport(int mreportId);
    @Select("select * from mreport where departmentId=#{departmentId}")
    List<mReport> getmReportByDepart(int departmentId);
    @Delete("delete from mreport where mreportId=#{mreportId}")
    void deletemReport(int mreportId);
    @Update("update mreport set userId=#{userId},departmentId=#{departmentId},mreportName=#{mreportName},mreportDate=#{mreportDate},status=#{status},summaryContents=#{summaryContents},planContents=#{planContents} where mreportId=#{mreportId}")
    void updatemReport(mReport mreport);
    @Select("select * from mreport")
    List<mReport> getAllmReport();
    @Select("select * from mreport where departmentId=#{departmentId} and mreportDate=#{mreportDate}")
    mReport getmReportByDepartmentAndDate(int departmentId,int mreportDate);

    @Select("SELECT department.departmentId FROM department where department.departmentId not in (select departmentId from mreport where mreport.mreportDate=#{mreportDate})")
    List<Integer> getDepartments(int mreportDate);
}
